package cn.kgc.waimai.service;


import cn.kgc.waimai.mapper.ShjiaMapper;
import cn.kgc.waimai.pojo.Shjia;
import cn.kgc.waimai.pojo.ShjiaExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @auhtor 司云杰
 * @create 2020-  03- 12-18:07
 */
@Service("businessService")
public class ShjiaServiceImpl implements ShjiaService {

    @Resource
    ShjiaMapper businessMapper;

    @Override
    public List<Shjia> SelectBusiness(String keyword) {

        if (keyword != null && keyword != "") {
            ShjiaExample example = new ShjiaExample();
            ShjiaExample.Criteria criteria = example.createCriteria();
            criteria.andShjnameLike("%" + keyword + "%");
            ShjiaExample.Criteria criteria2 = example.createCriteria();
            criteria2.andShjaddressLike("%" + keyword + "%");
            example.or(criteria2);
            List<Shjia> list = businessMapper.selectByExample(example);
            return list;
        } else {
            List<Shjia> list = businessMapper.selectByExample(null);
            return list;
        }
    }

    @Override
    public Shjia SelectBusinessById(int id) {
        return businessMapper.selectByPrimaryKey(id);
    }


}
